import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

// https://vite.dev/config/
export default defineConfig({
  base: '/', // 开启https访问时，使用 /， http访问时使用 ./
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  server: {
    proxy: {
      '/api': {
        // 本地联调部署后端环境需加端口号
        // target: 'http://8.137.37.23:6789',
        target: process.env.NODE_ENV === 'development' ? "http://localhost:6789" : 'http://8.137.37.23',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})